<div id="content_header">
  <h3>Assessment</h3>
</div>

<div class="row">


</div>

<div class="row">
  <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
    <dl>
      <dt>Term</dt>
      <dd>{{ courseschedule.Term.Number }} / {{ courseschedule.Term.Year }}</dd>
      <dt>Course</dt>
      <dd>{{ courseschedule.Course.CourseLevel.Name }}{{ courseschedule.Suffix ? (' - ' + courseschedule.Suffix) : '' }}</dd>
      <dt>Code</dt>
      <dd>{{ courseschedule.Course.CourseLevel.Code }}{{ courseschedule.Suffix ? (' - ' + courseschedule.Suffix) : '' }}</dd>
      <dt>Date</dt>
      <dd>{{ courseschedule.StartDate | date: 'mediumDate'  }} - {{ courseschedule.EndDate | date: 'mediumDate' }}</dd>
      <dt>Time</dt>
      <dd>{{ courseschedule.TimeClass.StartTime | date: 'shortTime'  }} - {{ courseschedule.TimeClass.EndTime | date: 'shortTime' }}</dd>
      <dt>Day</dt>
      <dd>{{ courseschedule.DayClass.DayRange }}</dd>
    </dl>
  </div>
  <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
    <dl>
      <dt>Class Type</dt>
      <dd>{{ TeacherTypes[courseschedule.Course.TeacherType].Code }}</dd>
      <dt>Teachers</dt>
      <dd ng-if="courseschedule.Staffs.length < 1">-</dd>
      <dd ng-repeat="teacher in courseschedule.Staffs">{{ teacher.Name }}</dd>
      <!-- <dt>Total Registered</dt>
      <dd>{{ registered.length }}</dd>
      <dt>Total Waiting List</dt>
      <dd>{{ waitingList.length }}</dd>
      <dt>Cancel/Move</dt>
      <dd>{{ cancelled.length }}</dd> -->
      <dt>Total</dt>
      <dd>{{ courseschedule.EnrollmentCount }}</dd>
      <dd>
        <a href ui-sref="courseSchedules.info({ id: courseschedule.Id })">Class Info</a>
        &nbsp
        <a href ui-sref="classes.raffled">Student Raffled</a>
        &nbsp
        <a href="http://203.84.138.181:8081/jasperserver/flow.html?_flowId=viewReportFlow&standAlone=true&_flowId=viewReportFlow&ParentFolderUri=%2Freports%2FAFAS%2FGELS&reportUnit=%2Freports%2FAFAS%2FGELS%2FIndividualStudentGE_GarisDinamis_Report&j_username=jasperadmin&j_password=jasperadmin&TermNumber={{ courseschedule.Term.Number }}&TermYear={{ courseschedule.Term.Year }}&CourseScheduleId={{ courseschedule.Id }}&output=pdf" target="_blank" ng-show="courseschedule.Course.CourseLevel.CourseType.Id == 2">Report</a>

        <a href="http://203.84.138.181:8081/jasperserver/flow.html?_flowId=viewReportFlow&standAlone=true&_flowId=viewReportFlow&ParentFolderUri=%2Freports%2FAFAS%2FGELS&reportUnit=%2Freports%2FAFAS%2FGELS%2FIndividualStudentSDReport&j_username=jasperadmin&j_password=jasperadmin&TermNumber={{ courseschedule.Term.Number }}&TermYear={{ courseschedule.Term.Year }}&CourseScheduleId={{ courseschedule.Id }}&output=pdf" target="_blank" ng-show="courseschedule.Course.CourseLevel.CourseType.Id == 1">Report</a>

        <a href="http://203.84.138.181:8081/jasperserver/flow.html?_flowId=viewReportFlow&standAlone=true&_flowId=viewReportFlow&ParentFolderUri=%2Freports%2FAFAS%2FGELS&reportUnit=%2Freports%2FAFAS%2FGELS%2FIndividualStudentSMP_Report&j_username=jasperadmin&j_password=jasperadmin&TermNumber={{ courseschedule.Term.Number }}&TermYear={{ courseschedule.Term.Year }}&CourseScheduleId={{ courseschedule.Id }}&output=pdf" target="_blank" ng-show="courseschedule.Course.CourseLevel.CourseType.Id == 4">Report</a>
      </dd>
    </dl>
  </div>
</div>

<div class="row">

  <div class="alert" ng-if="errors.errors.Score.length > 0">
    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
    <ul>
      <li ng-repeat="error in errors.errors.Score">{{ error }}</li>
    </ul>
  </div>


  <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 table-responsive">
    <table class="table table-bordered table-hover table-condensed">
      <thead>
        <tr>
          <th class="text-center" style="vertical-align: top;" >#</th>
          <th class="text-center" style="vertical-align: top;" >Student</th>
          <th class="text-center" style="vertical-align: top; min-width:70px;" ng-repeat="subject in subjects">
            {{ subject.Subject.Code }}
            <p class="help-block" ng-if="subject.Subject.ScoreType === 0"><small>{{ subject.Subject.RangeScore.LowerBound }} - {{ subject.Subject.RangeScore.Upperbound }}</small></p>
          </th>
          <th class="text-center" style="vertical-align: top;" >Ttl</th>
          <th class="text-center" style="vertical-align: top;" >Att (%)</th>
          <th class="text-center" style="vertical-align: top;" >Res</th>
          <th class="text-center" style="vertical-align: top;" >Comment</th>
          <th class="text-center" style="vertical-align: top;" >Best Std</th>
          <th class="text-center" style="vertical-align: top;" >Note</th>
          <th></th>
        </tr>
      </thead>
      <tbody>
        <!-- <tr dir-paginate="enrollment in enrollments | itemsPerPage: pagesize" total-items="totalItems"> -->
        <tr ng-repeat="enrollment in enrollments | orderBy:'StudentNameForOrder' track by $index">
          <td>{{ $index+1 }}</td>
          <td>
            {{ enrollment.StudentNameForOrder }}
          </td>
          <td ng-repeat="assessment in enrollment.Assessments | property:'Subject.IsActive': true">
            <div ng-if="assessment.Subject.ScoreType === 0">
              <input type="number" class="form-control input-sm" min="{{ assessment.Subject.RangeScore.LowerBound }}" max="{{ assessment.Subject.RangeScore.Upperbound }}" ng-model="assessment.Score">
            </div>
            <div ng-if="assessment.Subject.ScoreType === 1">
              <select name="lookup" id="lookup" class="form-control input-sm" ng-options="score.Id as score.Name for score in assessment.Subject.LookupScores | filter:{IsActive: 'true'}" ng-model="assessment.Score">
                <option value="" ng-hide="assessment.Score>-1">-</option>
              </select>
            </div>
          </td>
          <td class="text-right">{{enrollment.TotalScore}}</td>
          <td class="text-right">{{ enrollment.AttendancePercentage ? enrollment.AttendancePercentage : '-' }}</td>
          <td>
            <select name="CompletionStatus" id="CompletionStatus" class="form-control" ng-options="status.Id as status.Label for status in CourseCompletionStatus | filter:{Id: '!6'}" ng-model="enrollment.CourseCompletionStatus">
              <option value="" ng-hide="enrollment.CourseCompletionStatus>-1">Select an alphabet value</option>
            </select>
          </td>
          <td>
            <a href ng-click="openComment(enrollment)">Comment</a>
            <!-- <div class="pop-up-custom" ng-class="{ 'hidden': ! showComment }">
              <h3>Write a Comment <a href ng-click="showComment = ! showComment"><i class="fa fa-times"></i></a></h3>
              <textarea class="form-control" ng-model="enrollment.TeacherComment" ng-trim="false" maxlength="1010"></textarea>
              <p class="help-block"><span>{{1010 - enrollment.TeacherComment.length}} left</span></p>
            </div> -->
          </td>
          <td class="text-center"><input type="radio" ng-model="enrollment.IsBestStudent" ng-value="true" name="BestStudent" ng-change="handleRadioBestStudent(enrollment)" required /></td>
          <td>
            <p ng-bind-html="enrollment.Note | repComma" ng-if="enrollment.Note"></p>
            <span ng-hide="enrollment.Note">-</span>
            <!-- <a href ng-click="showNote = ! showNote">Note</a>
            <div class="pop-up-custom" ng-class="{ 'hidden': ! showNote }">
              <h3>Note <a href ng-click="showNote = ! showNote"><i class="fa fa-times"></i></a></h3>
              <p ng-bind-html="enrollment.Note | repComma"></p>
            </div> -->
          </td>
          <td>
            <a href ng-click="save(enrollment)" ng-disabled="!validation[enrollment.Id]">Save</a>
            <!-- <a href ui-sref="students.individual({id: enrollment.Id})">Report</a> -->
          </td>
        </tr>
      </tbody>
      <!-- <tfoot>
        <tr>

        </tr>
      </tfoot> -->
    </table>
    <div class="row">
      <div class="col-md-12 text-right">
        <button type="button" class="btn btn-primary" ng-click="saveAll()">Save All</button>
      </div>
    </div>
    <br>
    <!-- <dir-pagination-controls on-page-change="pageChanged(newPageNumber)" template-url="views/templates/dirPagination.tpl.html"></dir-pagination-controls> -->

  </div>
</div>

<pageslide ps-size="550px" ps-speed="0.25" ps-auto-close="true" ps-open="commentForm">
  <div style="padding:20px">
    <h3>Comment <a href="" ng-click="commentForm = !commentForm"><i class="simple-icon-close"></i></a></h3>
    <hr>
    <div class="media">
      <a class="pull-left" href>
        <img class="media-object" src="#" alt="Image">
      </a>
      <div class="media-body">
        <textarea class="form-control" ng-model="commentEnrollment.TeacherComment" ng-trim="false" maxlength="1010"></textarea>
        <p class="help-block"><span>{{1010 - commentEnrollment.TeacherComment.length}} characters left</span></p>
      </div>
    </div>
  </div>
</pageslide>